//
//  WPReadingFamousDoctorCell.m
//  wobingwoyi
//
//  Created by WGP on 16/8/23.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPReadingFamousDoctorCell.h"

@interface WPReadingFamousDoctorCell ()

@property(nonatomic,strong)UIImageView *coinImageView;
@property(nonatomic,strong)UILabel *coinCount;

@end
@implementation WPReadingFamousDoctorCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = GlobalBgColor;
        
        [self coinCount];
        [self coinImageView];
        
    }
    return self;
}

-(UILabel *)coinCount
{
    if (_coinCount == nil)
    {
        _coinCount = [UILabel new];
        _coinCount.font = [UIFont systemFontOfSize:14];
        _coinCount.textColor = RGB_COLOR(255, 169,77);
        _coinCount.text = @"88";
        [_coinCount sizeToFit];
        [self.myContentView addSubview:_coinCount];
        
        [_coinCount mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.myContentView).offset(-16);
            make.bottom.equalTo(self.myContentView).offset(-38);
        }];
    }
    return _coinCount;
}

-(UIImageView *)coinImageView
{

    if (_coinImageView == nil)
    {
        _coinImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"reading_coin"]];
        [_coinImageView sizeToFit];
        [self.myContentView addSubview:_coinImageView];
        
        [_coinImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.coinCount);
            make.right.equalTo(self.coinCount.mas_left).offset(-7);
        }];
    }
    return _coinImageView;
}

-(void)setModel:(WPMRModel *)model
{
    [super setModel:model];
    
    if(model.payable)
    {
        self.coinCount.text = [NSString stringWithFormat:@"%zd",model.pay];
    }
    else
    {
        self.coinCount.hidden = YES;
        self.coinImageView.hidden = YES;
    }
}

@end
